package com.yyhouc.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yyhouc.entity.User;
import com.yyhouc.mapper.UserMapper;
import com.yyhouc.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;


/**
 * 用户服务实现类
 * Created by wangfan on 2018-12-24 16:10
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    public boolean comparePsw(String dbPsw, String inputPsw) {
        return dbPsw != null && dbPsw.equals(encodePsw(inputPsw));
    }

    public String encodePsw(String psw) {
        if (psw == null) return null;
        return DigestUtils.md5DigestAsHex(psw.getBytes());
    }

}
